using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

namespace AIFSContentManagementSystem.DomainObjects
{
    using Mapper;

    public class Criteria : DomainObjects.DataTransferObject
    {
        int? criteriaId;

        public int? CriteriaId
        {
            get { return criteriaId; }
            set { criteriaId = value; }
        }

        List<CriterionExpression> criteriaExpression;

        public Criteria()
        {
            criteriaExpression = new List<CriterionExpression>();
            expressionFactory = new DefaultCriterionExpressionFactory();
        }

        ICriterionExpressionFactory expressionFactory;

        public Criteria(ICriterionExpressionFactory ExpressionFactory)
        {
            criteriaExpression = new List<CriterionExpression>();
            expressionFactory = ExpressionFactory;
        }

        /// <summary>
        /// This should be used internally.
        /// </summary>
        [System.Xml.Serialization.XmlIgnore]
        public List<CriterionExpression> CriteriaExpression
        {
            get
            {
                return criteriaExpression;
            }
            set
            {
                criteriaExpression = value;
            }
        }

        /// <summary>
        /// This should only be used for serialization. Do not use this for internal
        /// </summary>
        public string[] CriteriaExpressionArray
        {
            //not required only for XML serialization
            get
            {
                return new string[]{};
            }
            set
            {
                CriteriaMapper mapper = new CriteriaMapper(this.expressionFactory);
                criteriaExpression = mapper.Map(value);
            }
        }         
    }
}
